<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        //1.大括号
        let obj={
            name:"zhangsan",
            age:20
        }
        obj.height=156
        console.log(obj["name"])
        console.log(obj.name)
        console.log(obj.height)
        //2.new Objcet
        let obj1 =new Object()
        obj1.name="wangwu"
        obj1.age= 40
        obj1.height =250
        console.log(obj1.name)
        //3.构造函数(ES5及之前):本质还是函数
        function Person(){  
            this.name="zhangsan"
            this.age=20
            this.nihao= a=>{
                console.log(a)
            }
        }
        let b= new Person()
        console.log(b.name)
        
        let p2 =new Person("xiaohong",20,161)
        console.log(p2.name,p2.age)
        let p3 =new Person("dazhuang",30,180)
        //给对象加个方法
        p3.HowAreYou = function(a){
            console.log(a)
        }
        p3.HowAreYou("Hi")
        console.log(p3.name,p3.age)
        p3.nihao("你好")
    </script>
</body>
</html>